#ifndef __MY_STRUCT_H
#define __MY_STRUCT_H
#include "stm32f4xx_hal.h"

#define CONTROL_TIMER_CYCLE			0.01f	
#define Pi_v						3.1415f


#define ENCODER_TTL_COUNT_VALUE 	1000.0f			//轮子每圈的脉冲数
#define ROBOT_WHEEL_DIAMETER		0.0474f			//主动轮直径
#define ROBOT_WHEEL_WIDTH			0.185f			//机器人水平轮距,宽度
#define ROBOT_WHEEL_LENGTH		 	0.175f			//机器人垂直轮距,长度


#define CURRENT_MOTO_SPEED(X)  ((ROBOT_WHEEL_DIAMETER  *Pi_v * (X / ENCODER_TTL_COUNT_VALUE))/CONTROL_TIMER_CYCLE)
#define DX_TO_MOTOR(X) 			(ROBOT_WHEEL_DIAMETER  *Pi_v * (X / ENCODER_TTL_COUNT_VALUE));
typedef struct __Mpu6050_Str_
{
	short X_data;
	short Y_data;
	short Z_data;
}Mpu6050_Str;

typedef struct __Moto_Str_
{
	float Moto_CurrentSpeed;
	float Moto_TargetSpeed;
}Moto_Str;

typedef struct _Sensor_Str_
{
		unsigned int Header;	//EE FE FE FE FE
		float X_speed;			//00 00 00 00		
		float Y_speed;			//00 00 00 00
		float Z_speed;			//00 00 00 00
		float Source_Voltage;	//D7 E3 47 41
		
		Mpu6050_Str Link_Accelerometer;		//C4 06 F0 FD 6C 38
		Mpu6050_Str Link_Gyroscope;			//D8 FF 03 00 EB FF
		
		Moto_Str MotoStr[4];		//
		float PID_Param[3];					//00 00 00 00 00 00 00 00 00 00 00 00
		
		unsigned char End_flag;				//EE
}Sensor_Str;

typedef struct _Moto_
{
	int Encoder_Value;
	float Current_Speed;
	float Target_Speed;
	short ESC_Output_PWM;
	float L_Error;
	float LL_Error;
}_Moto_Str;

typedef struct light_t
{
	uint16_t right_light;
	uint16_t mid_light;
	uint16_t left_light;
}light_values;
typedef struct tracing_t
{
	int FLAG_GO_STATE;
	float error;
	float Previous_Error;
	float P;
	float I;
	float D;
	float pid_value;
	unsigned short init_pwm_speed;
	// float Target_speed_MOTO1;
	// float Target_speed_MOTO2;
	// float Initial_speed_MOTO1;
	// float Initial_speed_MOTO2;
	// float MOTO1_Current_Speed;
	// float MOTO2_Current_Speed;

}tracing_Str;

typedef struct tracing_pid_t
{
	float Kp;
	float Kd;
	float Ki;
}tracing_pid;
//左右路行驶路径
typedef struct _Path_len_
{
	double Left_len;
	double Right_len;

}Path_len;

typedef struct JY901S_ANGLE_t
{
	float my_Roll;
	float my_Pitch;
	float my_Yaw;
}JY901S_ANGLE;
// typedef union _Upload_Data_   
// {
// 	unsigned char buffer[PROTOCL_DATA_SIZE];
// 	struct _Sensor_Str_
// 	{
// 		unsigned int Header;	//EE FE FE FE FE
// 		float X_speed;			//00 00 00 00		
// 		float Y_speed;			//00 00 00 00
// 		float Z_speed;			//00 00 00 00
// 		float Source_Voltage;	//D7 E3 47 41
		
// 		Mpu6050_Str Link_Accelerometer;		//C4 06 F0 FD 6C 38
// 		Mpu6050_Str Link_Gyroscope;			//D8 FF 03 00 EB FF
		
// 		Moto_Str MotoStr[4];		//
// 		float PID_Param[3];					//00 00 00 00 00 00 00 00 00 00 00 00
		
// 		unsigned char End_flag;				//EE
// 	}Sensor_Str;
// }Upload_Data;

#endif // !__MY_STRUCT_H